package com.wicket.okrframework.web.contorller;

import com.github.pagehelper.Page;
import com.wicket.okrframework.biz.service.BusinessObjectService;
import com.wicket.okrframework.biz.service.dto.req.*;
import com.wicket.okrframework.biz.service.dto.res.*;
import com.wicket.okrframework.common.ro.OkrResult;
import com.wicket.okrframework.common.util.CommonFunctionHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/base/businessObject/")
public class BusinessObjectController {

    @Autowired
    BusinessObjectService businessObjectService;

    /**
   * D1-查询用户登录信息
   */
    @PostMapping("queryUserLoginInfo")
    public OkrResult<QueryUserLoginInfoRespDto> queryUserLoginInfo(@RequestBody @Validated QueryUserLoginInfoReqDto reqDTO){
    return OkrResult.success(businessObjectService.queryUserLoginInfo(reqDTO));
    }

    /**
   * D1-用户登录验证
   */
    @PostMapping("userLogin")
    public OkrResult<UserLoginRespDto> userLogin(@RequestBody @Validated UserLoginReqDto reqDTO){
    return OkrResult.success(businessObjectService.userLogin(reqDTO));
    }

    /**
   * D1-工号信息验证
   */
    @PostMapping("checkLoginNumber")
    public OkrResult<CheckLoginNumberRespDto> checkLoginNumber(@RequestBody @Validated CheckLoginNumberReqDto reqDTO){
    return OkrResult.success(businessObjectService.checkLoginNumber(reqDTO));
    }

    /**
   * D1-1批量查询业务对象列表（集合公用）
   */
    @PostMapping("batchQueryBizObjectList")
    public OkrResult<BatchQueryBizObjectListRespDto> batchQueryBizObjectList(@RequestBody @Validated BatchQueryBizObjectListReqDto reqDTO){
    return OkrResult.success(businessObjectService.batchQueryBizObjectList(reqDTO));
    }

    /**
   * D1-1查询对象属性类型关系列表
   */
    @PostMapping("queryObjTypeRelationList")
    public OkrResult<QueryObjTypeRelationListRespDto> queryObjTypeRelationList(@RequestBody @Validated QueryObjTypeRelationListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryObjTypeRelationListRespDto retData = businessObjectService.queryObjTypeRelationList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-1查询对象属性列表
   */
    @PostMapping("queryObjAttributeList")
    public OkrResult<QueryObjAttributeListRespDto> queryObjAttributeList(@RequestBody @Validated QueryObjAttributeListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryObjAttributeListRespDto retData = businessObjectService.queryObjAttributeList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * D1-1查询业务对象列表
   */
    @PostMapping("queryBizObjectList")
    public OkrResult<QueryBizObjectListRespDto> queryBizObjectList(@RequestBody @Validated QueryBizObjectListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        QueryBizObjectListRespDto retData = businessObjectService.queryBizObjectList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }

    /**
   * 登录成功生成Token
   */
    @PostMapping("createToken")
    public OkrResult<CreateTokenRespDto> createToken(@RequestBody @Validated CreateTokenReqDto reqDTO){
    return OkrResult.success(businessObjectService.createToken(reqDTO));
    }

    /**
   * D1-1查询对象属性详情
   */
    @PostMapping("queryObjAttributeDetail")
    public OkrResult<QueryObjAttributeDetailRespDto> queryObjAttributeDetail(@RequestBody @Validated QueryObjAttributeDetailReqDto reqDTO){
    return OkrResult.success(businessObjectService.queryObjAttributeDetail(reqDTO));
    }

    /**
   * D1-1修改对象属性类型关系
   */
    @PostMapping("updateObjTypeRelation")
    public OkrResult<UpdateObjTypeRelationRespDto> updateObjTypeRelation(@RequestBody @Validated UpdateObjTypeRelationReqDto reqDTO){
    return OkrResult.success(businessObjectService.updateObjTypeRelation(reqDTO));
    }

    /**
   * D1-1新增对象属性类型关系
   */
    @PostMapping("addObjTypeRelation")
    public OkrResult<AddObjTypeRelationRespDto> addObjTypeRelation(@RequestBody @Validated AddObjTypeRelationReqDto reqDTO){
    return OkrResult.success(businessObjectService.addObjTypeRelation(reqDTO));
    }

    /**
   * D1-1修改对象属性
   */
    @PostMapping("updateObjAttribute")
    public OkrResult<UpdateObjAttributeRespDto> updateObjAttribute(@RequestBody @Validated UpdateObjAttributeReqDto reqDTO){
    return OkrResult.success(businessObjectService.updateObjAttribute(reqDTO));
    }

    /**
   * D1-1新增对象属性
   */
    @PostMapping("addObjAttribute")
    public OkrResult<AddObjAttributeRespDto> addObjAttribute(@RequestBody @Validated AddObjAttributeReqDto reqDTO){
    return OkrResult.success(businessObjectService.addObjAttribute(reqDTO));
    }

    /**
   * D1-1查询业务对象详情
   */
    @PostMapping("queryBizObjectDetail")
    public OkrResult<QueryBizObjectDetailRespDto> queryBizObjectDetail(@RequestBody @Validated QueryBizObjectDetailReqDto reqDTO){
    return OkrResult.success(businessObjectService.queryBizObjectDetail(reqDTO));
    }

    /**
   * D1-1修改业务对象
   */
    @PostMapping("updateBizObject")
    public OkrResult<UpdateBizObjectRespDto> updateBizObject(@RequestBody @Validated UpdateBizObjectReqDto reqDTO){
    return OkrResult.success(businessObjectService.updateBizObject(reqDTO));
    }

    /**
   * D1-1新增业务对象
   */
    @PostMapping("addBizObject")
    public OkrResult<AddBizObjectRespDto> addBizObject(@RequestBody @Validated AddBizObjectReqDto reqDTO){
    return OkrResult.success(businessObjectService.addBizObject(reqDTO));
    }

    /**
     * D1-1删除业务场景---待删除
     */
    @PostMapping("deleteBizScene")
    public OkrResult<DeleteBizSceneRespDto> deleteBizScene(@RequestBody @Validated DeleteBizSceneReqDto reqDTO) {
        return OkrResult.success(businessObjectService.deleteBizScene(reqDTO));
    }

    /**
     * D1-1删除业务应用---待删除
     */
    @PostMapping("deleteBizAppScene")
    public OkrResult<DeleteBizAppSceneRespDto> deleteBizAppScene(@RequestBody @Validated DeleteBizAppSceneReqDto reqDTO) {
        return OkrResult.success(businessObjectService.deleteBizAppScene(reqDTO));
    }

    /**
     * D1-1删除对象属性类型关系
     */
    @PostMapping("deleteObjTypeRelation")
    public OkrResult<DeleteObjTypeRelationRespDto> deleteObjTypeRelation(@RequestBody @Validated DeleteObjTypeRelationReqDto reqDTO) {
        return OkrResult.success(businessObjectService.deleteObjTypeRelation(reqDTO));
    }

    /**
     * D1-3新增就职记录
     */
    @PostMapping("addInductionRecord")
    public OkrResult<AddInductionRecordRespDto> addInductionRecord(@RequestBody @Validated AddInductionRecordReqDto reqDTO) {
        return OkrResult.success(businessObjectService.addInductionRecord(reqDTO));
    }

    /**
     * D1-1删除对象属性
     */
    @PostMapping("deleteObjAttribute")
    public OkrResult<DeleteObjAttributeRespDto> deleteObjAttribute(@RequestBody @Validated DeleteObjAttributeReqDto reqDTO) {
        return OkrResult.success(businessObjectService.deleteObjAttribute(reqDTO));
    }
/**
   * D1-1删除标签
   */
    @PostMapping("deleteTag")
    public OkrResult<DeleteTagRespDto> deleteTag(@RequestBody @Validated DeleteTagReqDto reqDTO){
    return OkrResult.success(businessObjectService.deleteTag(reqDTO));
    }
/**
   * D1-1批量查询对象属性列表
   */
    @PostMapping("batchQueryObjAttributeList")
    public OkrResult<BatchQueryObjAttributeListRespDto> batchQueryObjAttributeList(@RequestBody @Validated BatchQueryObjAttributeListReqDto reqDTO){
    Page<?> page = CommonFunctionHelper.startPage(reqDTO.getPageNum(),reqDTO.getPageSize());

        BatchQueryObjAttributeListRespDto retData = businessObjectService.batchQueryObjAttributeList(reqDTO);

        retData.setPageNum(page.getPageNum());
        retData.setPageSize(page.getPageSize());
        retData.setTotalNum(page.getTotal());
        return OkrResult.success(retData);
    
    }
/**
   * D1查询对象属性列表(公共)
   */
    @PostMapping("queryObjAttributeListCom")
    public OkrResult<QueryObjAttributeListComRespDto> queryObjAttributeListCom(@RequestBody @Validated QueryObjAttributeListComReqDto reqDTO){
    return OkrResult.success(businessObjectService.queryObjAttributeListCom(reqDTO));
    }
}
